package com.medicine.web.controller.manage.block;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.medicine.common.annotation.Log;
import com.medicine.common.core.controller.BaseController;
import com.medicine.common.core.domain.AjaxResult;
import com.medicine.common.enums.BusinessType;
import com.medicine.manage.block.domain.UserExtend;
import com.medicine.manage.block.service.IUserExtendService;
import com.medicine.common.utils.poi.ExcelUtil;
import com.medicine.common.core.page.TableDataInfo;

/**
 * 区块链用户管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/manage/extend")
public class UserExtendController extends BaseController
{
    @Autowired
    private IUserExtendService userExtendService;

    /**
     * 查询区块链用户管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:extend:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserExtend userExtend)
    {
        startPage();
        List<UserExtend> list = userExtendService.selectUserExtendList(userExtend);
        return getDataTable(list);
    }

    /**
     * 导出区块链用户管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:extend:export')")
    @Log(title = "区块链用户管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserExtend userExtend)
    {
        List<UserExtend> list = userExtendService.selectUserExtendList(userExtend);
        ExcelUtil<UserExtend> util = new ExcelUtil<UserExtend>(UserExtend.class);
        util.exportExcel(response, list, "区块链用户管理数据");
    }

    /**
     * 获取区块链用户管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:extend:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(userExtendService.selectUserExtendByUserId(userId));
    }

    /**
     * 新增区块链用户管理
     */
    @PreAuthorize("@ss.hasPermi('manage:extend:add')")
    @Log(title = "区块链用户管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserExtend userExtend)
    {
        return toAjax(userExtendService.insertUserExtend(userExtend));
    }

    /**
     * 修改区块链用户管理
     */
    @PreAuthorize("@ss.hasPermi('manage:extend:edit')")
    @Log(title = "区块链用户管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserExtend userExtend)
    {
        return toAjax(userExtendService.updateUserExtend(userExtend));
    }

    /**
     * 删除区块链用户管理
     */
    @PreAuthorize("@ss.hasPermi('manage:extend:remove')")
    @Log(title = "区块链用户管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(userExtendService.deleteUserExtendByUserIds(userIds));
    }
}
